/**
 * 
 */
package com.qolome.order.controller;

import java.util.Date;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qolome.order.message.StreamClient;

/**
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author 姜锋
 * @date 2020年1月21日 下午6:56:46 
 * @version V1.0   
 *
 */
@RestController
@RequestMapping("/mq")
public class MqController {
	@Autowired
	private AmqpTemplate amqpTemplate;
	
	@Autowired
	private StreamClient streamClient;

	public void send() {
		amqpTemplate.convertAndSend("orderQueue", "now " + new Date());
	}
	
	
	@GetMapping("/sendMessage")
	public void sendMessage() {
		streamClient.output()
		.send(MessageBuilder.withPayload("着急忙慌的测试中")
				.build());
	}
	
	@GetMapping("/sendOrder")
	public void sendOrder() {
		amqpTemplate.convertAndSend("computerQueue", "computer", "联想小新Air13Pro");
		amqpTemplate.convertAndSend("computerQueue", "computer", "雷神911 Air");
		amqpTemplate.convertAndSend("computerQueue", "computer",
				"联想(Lenovo)拯救者Y7000P 2019英特尔酷睿i715.6英寸游戏笔记本电脑(i7-9750H 16G 1T SSD GTX1660Ti 144Hz)");
		amqpTemplate.convertAndSend("orderQueue", "furnitureQueue",
				"百富帝（byford）四件套纯棉家纺 床上用品床单枕套双人全棉斜纹套件1.5/1.8米床被套200*230 慕尼黑");
		amqpTemplate.convertAndSend("orderQueue", "furnitureQueue",
				"博洋家纺（BEYOND）床品套件 纯棉四件套北欧风全棉斜纹床单被套双人床1.8m床上用品 西莉雅220*240cm");
		amqpTemplate.convertAndSend("orderQueue", "furnitureQueue",
				"雅鹿·自由自在 四件套纯棉家纺 床上用品床单被套枕套全棉斜纹套件 1.5米/1.8米床 被套200*230cm 休闲午后");
		amqpTemplate.convertAndSend("estateQueue", "estate", "【安徽区域】置业华东京选富力 99折资格");
		amqpTemplate.convertAndSend("estateQueue", "estate", "林肯时代十年匠心回归亦庄");
		amqpTemplate.convertAndSend("estateQueue", "estate", "置业华东京选富力 98折资格（补交专用）");
	}
	
}
